<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:app="http://springfuse.jaxio.com/app"
	xmlns:p="http://primefaces.org/ui"
	template="/WEB-INF/layouts/#{print ? 'print' : 'main'}.xhtml">
	<ui:define name="toolbarChildren">
		<p:toolbarGroup>
			<p:commandButton id="print" value="#{msg.menu_print}" action="#{bean.print()}" rendered="#{bean.entity.idSet}"
				icon="ui-icon-print" immediate="true" ajax="false" />
		</p:toolbarGroup>
		<p:toolbarGroup rendered="#{sub or readonly}">
			<p:commandButton id="back" action="#{bean.back()}" process="@none" ajax="false" immediate="true"
				value="#{msg.back}" icon="ui-icon-arrowreturnthick-1-w" />
		</p:toolbarGroup>
		<p:toolbarGroup rendered="#{not sub and not readonly}">
			<p:commandButton id="close" oncomplete="askForSaveDialog.show(); APP.focusAskForSaveDialog();"
				ajax="true" immediate="true" process="@this"
				icon="ui-icon-close"
				value="#{msg.menu_close}"
				title="#{msg.menu_close} #{resourcesUtil.getProperty(title)}"/>
			<p:commandButton id="delete" icon="ui-icon-trash"
				onclick="askForDeleteDialog.show(); APP.focusAskForDeleteDialog();"
				value="#{msg.menu_delete_and_close}"
				title="#{msg.menu_delete_and_close} #{resourcesUtil.getProperty(title)}"
				disabled="#{empty bean.entity.id}"
				rendered="#{permission.canDelete(bean.entity)}" />
			<p:separator />
		</p:toolbarGroup>
	</ui:define>
	<ui:define name="content">
		<p:breadCrumb model="#{conversationBreadCrumb.model}" rendered="#{conversationBreadCrumb.render}" />
		<p:fieldset id="fieldset">
			<input type="hidden" name="_cid" value="#{conversationManager.currentConversation.cid}"/>
			<f:validateBean disabled="true">
				<h:panelGrid columns="2" styleClass="aria-role-presentation">
					<ui:insert name="form" />
				</h:panelGrid>
				<app:saveButton title="#{title}" bean="#{bean}"/>
			</f:validateBean>
		</p:fieldset>
		<p:tabView id="tabs" activeIndex="#{bean.tabBean.activeIndex}" rendered="#{not empty bean.tabBean and not print}">
			<p:ajax event="tabChange" />
			<ui:insert name="tabs"/>
		</p:tabView>
		<p:accordionPanel id="tabsPrint" activeIndex="0,1,2,3,4,5,6,7,8,9,10" cache="false" multiple="true" 
			rendered="#{not empty bean.tabBean and print}">
			<ui:insert name="tabs"/>
		</p:accordionPanel>
	</ui:define>
	<ui:define name="dialogs">
		<ui:insert name="custom-dialogs" />
		<p:confirmDialog widgetVar="askForDeleteDialog" header="#{msg.menu_delete}?" message="#{msg.dialog_delete_confirm}">
			<h:panelGrid id="askForDeleteDialogContent" columns="1" cellpadding="4" style="margin:0 auto;">
				<h:outputText value="#{printer.print(bean.entity)}" style="font-weight:bold" />
			</h:panelGrid>
			<p:commandButton id="askForDeleteDialogYes" action="#{bean.deleteAndClose()}" ajax="false" immediate="true" process="@none" value="#{msg.yes}" title="#{msg.dialog_delete_confirm} #{msg.yes}" icon="ui-icon-check" />
			<p:commandButton id="askForDeleteDialogNo" value="#{msg.no}" title="#{msg.dialog_delete_confirm} #{msg.no}" onclick="askForDeleteDialog.hide(); APP.focusTo('form:delete'); return false;" icon="ui-icon-cancel"/>
		</p:confirmDialog>
		<p:confirmDialog widgetVar="askForSaveDialog" header="#{msg.menu_save}?" message="#{msg.dialog_ask_for_save}">
			<p:commandButton id="askForSaveDialogYes" action="#{bean.saveAndClose()}" ajax="true" process="@form" value="#{msg.yes}"
				title="#{msg.dialog_ask_for_save} #{msg.yes}"
				onstart="askForSaveDialog.hide()"
				styleClass="aria-save-button"
				update="messages" icon="ui-icon-check" />
			<p:commandButton id="askForSaveDialogNo" action="#{bean.forceClose()}" ajax="false"
				value="#{msg.no}"
				title="#{msg.dialog_ask_for_save} #{msg.no}"
				icon="ui-icon-cancel" immediate="true" process="@none" />
		</p:confirmDialog>
	</ui:define>
</ui:composition>